
#include "vk1.h"
#include <vulkan/vulkan.h>
#include <vector>

#pragma comment(lib, "vulkan-1.lib")

VkInstance instance;

bool init_vk()
{
	VkResult result = VK_SUCCESS;
	VkApplicationInfo appInfo = {};
	VkInstanceCreateInfo instanceCreateInfo = {};

	// instance.
	appInfo.sType = VK_STRUCTURE_TYPE_APPLICATION_INFO;
	appInfo.pApplicationName = "vKApplication";
	appInfo.applicationVersion = 1;
	appInfo.apiVersion = VK_MAKE_VERSION(1,0,0);

	instanceCreateInfo.sType = VK_STRUCTURE_TYPE_INSTANCE_CREATE_INFO;
	instanceCreateInfo.pApplicationInfo = &appInfo;

	result = vkCreateInstance(&instanceCreateInfo,nullptr,&instance);
	if (result != VK_SUCCESS)
	{
		return false;
	}

	// physical devices.
	uint32_t physicalDeviceCount = 0;
	vkEnumeratePhysicalDevices(instance,&physicalDeviceCount,nullptr);
	if (physicalDeviceCount == 0)
		return false;

	std::vector<VkPhysicalDevice> pysicalDevices;
	pysicalDevices.resize(physicalDeviceCount);
	vkEnumeratePhysicalDevices(instance, &physicalDeviceCount, pysicalDevices.data());

	uint32_t selectedDevice = 0;
	VkPhysicalDeviceProperties deviceProperties;
	vkGetPhysicalDeviceProperties(pysicalDevices[selectedDevice], &deviceProperties);

	VkPhysicalDeviceFeatures deviceFeatures;
	vkGetPhysicalDeviceFeatures(pysicalDevices[selectedDevice], &deviceFeatures);

	VkPhysicalDeviceMemoryProperties deviceMemoryProperties;
	vkGetPhysicalDeviceMemoryProperties(pysicalDevices[selectedDevice],&deviceMemoryProperties);

	return true;
}

